using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing;

namespace Lx.Web.Common.UI
{
    [ParseChildren(false), ToolboxItem(false)]
    public class Style : Control
    {
        public Style() { }
        protected override void Render(HtmlTextWriter output)
        {
            if (path.StartsWith("~/"))
            {
                path = path.Replace("~", System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/'));
            }
            //output.Write("<link type=\"text/css\" rel=\"stylesheet\" href=\"" + System.Web.HttpUtility.HtmlAttributeEncode(path) + "\"></link>");
            output.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
            output.AddAttribute(HtmlTextWriterAttribute.Href, path);
            output.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet");
            output.RenderBeginTag(HtmlTextWriterTag.Link);
            output.RenderEndTag();
        }
        string path = string.Empty;
        public string Path
        {
            get
            {
                return path;
            }
            set
            {
                path = value;
            }
        }        
    }
}